from pymysql import *
# 连接数据库
conn = connect(host='localhost', user='root', password='123456', database='house_data', port=3306)
# 游标
cursor = conn.cursor()

def querys(sql, params, type='no_select'):
    # 因为数据库操作结果为元组
    params = tuple(params)
    cursor.execute(sql, params)
    # 查询
    if type != 'no_select':
        data_list = cursor.fetchall()
        conn.commit()
        return data_list
    # 增、删、改等
    else:
        conn.commit()
        return "数据库语句执行成功"